package com.lxw.weather.activity;

import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.lxw.weather.R;

public class WeatherIndexActivity extends AppCompatActivity {

    private TextView aqiValueText, pm25ValueText, humidityValueText, pressureValueText, visibilityValueText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.weather_index_activity);

        initUIComponents();
        displayWeatherIndexData();
    }

    private void initUIComponents() {
        aqiValueText = findViewById(R.id.aqiValue);
        pm25ValueText = findViewById(R.id.pm25Value);
        humidityValueText = findViewById(R.id.humidityValue);
        pressureValueText = findViewById(R.id.pressureValue);
        visibilityValueText = findViewById(R.id.visibilityValue);
    }

    private void displayWeatherIndexData() {
        // 获取从MainActivity传递过来的天气指数数据
        String aqiData = getIntent().getStringExtra("aqiData");
        String pm25Data = getIntent().getStringExtra("pm25Data");
        String humidityData = getIntent().getStringExtra("humidityData");
        String pressureData = getIntent().getStringExtra("pressureData");
        String visibilityData = getIntent().getStringExtra("visibilityData");

        // 显示天气指数数据
        if (aqiData != null) {
            aqiValueText.setText(aqiData);
        }

        if (pm25Data != null) {
            pm25ValueText.setText(pm25Data);
        }

        if (humidityData != null) {
            humidityValueText.setText(humidityData);
        }

        if (pressureData != null) {
            pressureValueText.setText(pressureData);
        }

        if (visibilityData != null) {
            visibilityValueText.setText(visibilityData);
        }
    }
}